package io.sdl.service.impl;

import io.sdl.common.service.impl.BaseServiceImpl;
import io.sdl.common.utils.ConvertUtils;
import io.sdl.dao.SdlDiaryCommentsDao;
import io.sdl.dto.SdlDiaryCommentsDTO;
import io.sdl.entity.SdlDiaryCommentsEntity;
import io.sdl.service.SdlDiaryCommentsService;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("sdlDiaryCommentsService")
public class SdlDiaryCommentsServiceImpl extends BaseServiceImpl<SdlDiaryCommentsDao, SdlDiaryCommentsEntity> implements SdlDiaryCommentsService {


    @Override
    public List<SdlDiaryCommentsDTO> selectByDiaryId(Long diaryId) {
        List<SdlDiaryCommentsEntity> list = baseDao.selectByDiaryId(diaryId);

        return ConvertUtils.sourceToTarget(list, SdlDiaryCommentsDTO.class);
    }

    //根据评论id查询下面的子评论
    @Override
    public List<SdlDiaryCommentsDTO> selectByPid(Long parentId) {
        List<SdlDiaryCommentsEntity> list = baseDao.selectByPid(parentId);
        return ConvertUtils.sourceToTarget(list, SdlDiaryCommentsDTO.class);
    }

}